<template>
  <PageTabelLayout>
    <template #pageHeader>
      <div class="my-header" v-if="headerShow">
        <a-form size="small" :model="searchData" auto-label-width layout="inline">


          <a-form-item label="开单日期" label-col-flex="80px" :style="{width:'320px'}">
            <a-range-picker popup-container="html" class="bacClass"/>
          </a-form-item>


          <a-form-item label="流转卡号" label-col-flex="80px" :style="{width:'320px'}">
            <a-input class="bacClass" allow-clear/>
          </a-form-item>


          <a-form-item label="记录单号" label-col-flex="80px" :style="{width:'320px'}">
            <a-input class="bacClass" allow-clear/>
          </a-form-item>


          <a-form-item label="布号" label-col-flex="80px" :style="{width:'320px'}">
            <a-input class="bacClass" allow-clear/>
          </a-form-item>


          <a-form-item label="品名" label-col-flex="80px" :style="{width:'320px'}">
            <a-input class="bacClass" allow-clear/>
          </a-form-item>


          <a-form-item label="客户名称" label-col-flex="80px" :style="{width:'320px'}">
            <a-input class="bacClass" allow-clear/>
          </a-form-item>


        </a-form>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up v-if="headerShow" @click="changHeadShow(false)" :strokeWidth="2" :size="18"/>
          <icon-double-down v-else @click="changHeadShow(true)" :strokeWidth="2" :size="18"/>
        </a-divider>
      </div>
      <div class="my-tool-bar" style="margin-bottom: 10px;">
        <Toolbar :items="['查询', '新增', '审核', '导出']" @add="addHandler" @select="selectHandler"
                 @export="exportHandler"
                 @audit="auditHandler" v-if="auditState === 0"/>
        <Toolbar :items="['查询', '导出']" @select="selectHandler" @export="exportHandler" v-if="auditState === 1"/>
      </div>
    </template>
    <template #pageTabel>
      <div style="height:100%;overflow-y:auto ;">
        <a-tabs   :lazy-load="true" :default-active-key="0" trigger="click" @change="changHandler" justify>
          <a-tab-pane :key="0" title="未审核">
            <div style="height:85%">
              <shinkageTestUnApproved @chang-auids="changAuids" :searchData="searchData"/>
            </div>
          </a-tab-pane>
          <a-tab-pane :key="1" title="已审核">
            <div style="height:85%">
              <shinkageTestApproved @chang-auids="changAuids" :searchData="searchData"/>
            </div>

          </a-tab-pane>
        </a-tabs>
      </div>
    </template>
  </PageTabelLayout>
  <a-drawer :drawer-style="{ zIndex: 9999 }" height="100%" unmountOnClose :visible="pageData.showAdd"
            :mask-closable="false" placement="bottom" @cancel="pageData.showAdd = false">
    <template #title>
      <a-row style="width:100%;justify-content: space-between;box-sizing: border-box;">
        <a-col flex="260px"> {{ pageData.sideTitle }}</a-col>
      </a-row>
    </template>
    <a-form ref="formRef" style="margin-top:20px" layout="horizontal" auto-label-width :model="pageData">
      <a-row :span="6">
        <a-col :xxl="6" :xl="12" :lg="12" :md="12" :xs="24">
          <a-form-item label="开单日期" field="billDate" :rules="[{ required: true, message: '开单日期必填' }]"
                       :validate-trigger="['change', 'blur']">
            <a-date-picker popup-container="html" showTime style="width: 270px;" v-model="pageData.billDate"/>
          </a-form-item>
        </a-col>
        <a-col :xxl="6" :xl="12" :lg="12" :md="12" :xs="24">
          <a-form-item label="流转卡号">
            <!-- <a-select popup-container="html"  style="width: 270px;" @change="selectChange" allow-clear @focus="selecChange(1)"
                allow-search @search="seatchHandler($event, 1)">
                <a-option v-for="item in pageData.circulDropList" :key="item.id" :value="item.flowCardCode">{{
                    item.flowCardCode }}</a-option>
            </a-select> -->
            <a-input style="width: 270px;" v-model="pageData.circulatCard" allow-clear class="bacClass"
                     @press-enter="selectChange"/>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
    <a-table :columns="createTableColumns" :scrollbar="scrollbar" sticky-header stripe :bordered="{ headerCell: true }"
             :rowKey="rowKey" :data="createTableData.dataForm" style="height:260px" :key="Math.random()"
             :pagination="false">
      <template #circulatCard="{ rowIndex }">
        <a-input disabled v-model="createTableData.dataForm[rowIndex].circulatCard"/>
      </template>
      <template #customName="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].customName"/>
      </template>
      <template #clothCode="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].clothCode"/>
      </template>
      <template #brandName="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].brandName"/>
      </template>
      <template #colorDepth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].colorDepth"/>
      </template>
      <template #colorCode="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].colorCode"/>
      </template>
      <template #colorName="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].colorName"/>
      </template>
      <template #contractNo="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].contractNo"/>
      </template>
      <template #customOrderNo="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].customOrderNo"/>
      </template>
      <template #greyBatch="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].greyBatch"/>
      </template>
      <template #greyName="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].greyName"/>
      </template>
      <template #pieceNum="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].pieceNum"/>
      </template>
      <template #deviceCode="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].deviceCode"/>
      </template>
      <template #shapMachine="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].shapMachine"/>
      </template>
      <template #preshrunk="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].preshrunk"/>
      </template>
      <template #weight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].weight"/>
      </template>
      <template #firstGreyWashWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstGreyWashWeight"/>
      </template>
      <template #firstGreyWashWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].firstGreyWashWidth"/>
      </template>
      <template #afterGreyWashWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterGreyWashWeight"/>
      </template>
      <template #afterGreyWashWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].afterGreyWashWidth"/>
      </template>
      <template #firstSetWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstSetWeight"/>
      </template>
      <template #firstSetWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].firstSetWidth"/>
      </template>
      <template #reductionWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].reductionWeight"/>
      </template>
      <template #reductionWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].reductionWidth"/>
      </template>
      <template #afterSetWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterSetWeight"/>
      </template>
      <template #afterSetWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].afterSetWidth"/>
      </template>
      <template #washSizeChangeRateType="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].washSizeChangeRateType"/>
      </template>
      <template #firstWashTransverse1="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashTransverse1"/>
      </template>
      <template #firstWashTransverse2="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashTransverse2"/>
      </template>
      <template #firstWashTransverse3="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashTransverse3"/>
      </template>
      <template #firstWashTransverseAvg="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].firstWashTransverseAvg"/>
      </template>
      <template #firstWashStraight1="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashStraight1"/>
      </template>
      <template #firstWashStraight2="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashStraight2"/>
      </template>
      <template #firstWashStraight3="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashStraight3"/>
      </template>
      <template #firstWashStraightAvg="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].firstWashStraightAvg"/>
      </template>
      <template #afterWashTransverse1="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashTransverse1"/>
      </template>
      <template #afterWashTransverse2="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashTransverse2"/>
      </template>
      <template #afterWashTransverse3="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashTransverse3"/>
      </template>
      <template #afterWashTransverseAvg="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].afterWashTransverseAvg"/>
      </template>
      <template #afterWashStraight1="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashStraight1"/>
      </template>
      <template #afterWashStraight2="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashStraight2"/>
      </template>
      <template #afterWashStraight3="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashStraight3"/>
      </template>
      <template #afterWashStraightAvg="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].afterWashStraightAvg"/>
      </template>
      <template #shrinkageHangDryTransverse="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].shrinkageHangDryTransverse"/>
      </template>
      <template #shrinkageHangDryStraight="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].shrinkageHangDryStraight"/>
      </template>
      <template #shrinkageThrowDryTransverse="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].shrinkageThrowDryTransverse"/>
      </template>
      <template #shrinkageThrowDryStraight="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].shrinkageThrowDryStraight"/>
      </template>
      <template #shrinkageFlatDryTransverse="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].shrinkageFlatDryTransverse"/>
      </template>
      <template #shrinkageFlatDryStraight="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].shrinkageFlatDryStraight"/>
      </template>
      <template #torsionHangDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].torsionHangDry"/>
      </template>
      <template #torsionThrowDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].torsionThrowDry"/>
      </template>
      <template #torsionFlatDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].torsionFlatDry"/>
      </template>
      <template #washWeightHangDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].washWeightHangDry"/>
      </template>
      <template #washWeightThrowDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].washWeightThrowDry"/>
      </template>

      <template #washWeightFlatDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].washWeightFlatDry"/>
      </template>
      <template #requireWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].requireWidth"/>
      </template>
      <template #validWidth="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].validWidth"/>
      </template>
      <template #requireWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].requireWeight"/>
      </template>
      <template #measuredWeight="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].measuredWeight"/>
      </template>
      <template #burstStrength="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].burstStrength"/>
      </template>
      <template #dilapidationStrength="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].dilapidationStrength"/>
      </template>
      <template #SunColorFastness="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].SunColorFastness"/>
      </template>
      <template #phenolYellowColorFastness="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].phenolYellowColorFastness"/>
      </template>
      <template #phValue="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].phValue"/>
      </template>
      <template #formaldehyde="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].formaldehyde"/>
      </template>
      <template #latitudinalObliquity="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].latitudinalObliquity"/>
      </template>
      <template #lightSweatColorFastnessSour="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].lightSweatColorFastnessSour"/>
      </template>
      <template #lightSweatColorFastnessAlkali="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].lightSweatColorFastnessAlkali"/>
      </template>
      <template #soakWater="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].soakWater"/>
      </template>
      <template #verticalDensityCPI="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].verticalDensityCPI"/>
      </template>
      <template #transverseDensityCPI="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].transverseDensityCPI"/>
      </template>
      <template #frictionColorFastnessDry="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].frictionColorFastnessDry"/>
      </template>
      <template #frictionColorFastnessWetTint="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].frictionColorFastnessWetTint"/>
      </template>
      <template #frictionColorFastnessWetDark="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].frictionColorFastnessWetDark"/>
      </template>
      <template #soapWashColorFastness="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].soapWashColorFastness"/>
      </template>
      <template #stainColorFastnessSour="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].stainColorFastnessSour"/>
      </template>
      <template #stainColorFastnessAlkali="{ rowIndex }">
        <a-input-number :min="0" class="cInput"
                        v-model="createTableData.dataForm[rowIndex].stainColorFastnessAlkali"/>
      </template>
      <template #waterColorFastness="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].waterColorFastness"/>
      </template>
      <template #resistPill="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].resistPill"/>
      </template>
      <template #salivaColorFastness="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].salivaColorFastness"/>
      </template>
      <template #remark="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].remark"/>
      </template>
      <template #consumption="{ rowIndex }">
        <a-input-number :min="0" class="cInput" v-model="createTableData.dataForm[rowIndex].consumption"/>
      </template>
      <template #verifyStandard="{ rowIndex }">
        <a-input class="cInput" v-model="createTableData.dataForm[rowIndex].verifyStandard"/>
      </template>
    </a-table>

    <template #footer>
      <a-button size="mini" @click="pageData.showAdd = false">
        关闭
      </a-button>
      <a-button type="primary" size="mini" @click="saveHandler">
        保存
      </a-button>
      <a-button type="primary" status="warning" size="mini" @click="dyBoufeiHandler" v-if="createTableData.id">
        打印
      </a-button>
    </template>
  </a-drawer>
</template>

<script lang="ts">
import {reactive, ref, onMounted} from 'vue'
import {useTable, useRowKey, useTableColumn, usePagination, useRowSelection} from '@/hooks/table'
import {shinkageTestForm} from '@/interface/phyShinkageTestForm';
import {verfiyShrinkReg} from '@/api/PhysicalSurveyRoom/physicalTestApi'
import {FormInstance, Message, Modal} from '@arco-design/web-vue';
import {orderFn as labOtherFn} from '@/api/laboratory/other'
import PageTabelLayout from '@/components/pageTabelLayout.vue';
import emitter from "@/hooks/useEventBus";
import dayjs from 'dayjs';

export default {
  name: "shinkageTestOrignalRegistForm",
  setup() {
    const verfiyShrinkRegApi = verfiyShrinkReg();
    const auditState = ref(0);
    const searchData = ref({});
    let headerShow = ref<boolean>(true);
    let changHeadShow = (boolVal: boolean) => {
      headerShow.value = boolVal;
      emitter.emit('window-change');
    };
    onMounted(() => {
      // 第一个页面需要在刚进入就调用一次  切换tap时也需要调用
      emitter.emit('shinkageTestUnApproved');
    });

    const addHandler = () => {
      createTableData.dataForm.forEach(v => {
        for (var key in v) {
          v[key] = null;
        }
      });
      pageData.billDate = dayjs(Date.now()).format('YYYY-MM-DD hh:mm:ss');
      pageData.circulatCard = ''
      pageData.showAdd = true;
      pageData.sideTitle = "新增缩水测试原始资料登记";
    };
    //下拉数据
    const options = ref<any>();
    const loading = ref(false);
    const seatchHandler = async (value: any, index: number) => {
      if (value) {
        loading.value = true;
        await selecChange(index, value, (data: any) => {
          options.value = data;
        });
        loading.value = false;
      } else {
        options.value = [];
      }
    };
    const selecChange = async (selectIndex: number, value: any = "", cb = (data: any) => {
      return data;
    }) => {
      //获取流转卡号下拉列表信息数据
      await labOtherFn().getCirculDropList({flowCardCode: value,}).then(res => {
        if (res.code === 200) {
          pageData.circulDropList = res.data;
          cb(res.data);
        } else {
          Message.error({
            content: "查询失败！",
            duration: 5000,
          });
        }
      });
    };
    const selectChange = async () => {
      createTableData.dataForm = [{...dataFormItem}];
      await verfiyShrinkRegApi.getCirculatCardBriData({circulatCard: pageData.circulatCard}).then(res => {
        if (res.code === 200) {
          let data = res.data;
          if (Array.isArray(data) && data.length > 0) {
            createTableData.dataForm.forEach((v) => {
              data.forEach((item: any, sI: any) => {
                createTableData.dataForm[sI] = {...v, ...item};
              });
            });
          }
        }
      });
    };
    const selectHandler = () => {
      if (auditState.value === 0) {
        emitter.emit('shinkageTestUnApproved');
      } else {
        emitter.emit('shinkageTestApproved');
      }
    };
    const auditHandler = async () => {
      if (auditState.value === 0) {
        emitter.emit('changTestUnApprovedRows');
      } else {
        emitter.emit('changTestApprovedRows');
      }
    };
    const changAuids = (auids: any) => {
      // console.log(auids);
      let vals = auids.map((v: any) => {
        return v.id
      });
      if (vals.length > 0) {
        Modal.confirm({
          title: "提示",
          content: `确定要${auditState.value > 0 ? "驳回审核" : "审核"}选中数据吗？`,
          cancelText: "取消",
          okText: "审核",
          onOk: async () => {
            let data = vals.map((item: any) => {
              return {
                id: item,
                auditState: auditState.value > 0 ? '2' : '1'
              };
            });
            await verfiyShrinkRegApi.setAuditVerfiyShrinkReg([...data]).then((res: any) => {
              if (res.code === 200) {
                Message.success({
                  content: res.message || "操作成功",
                  duration: 2000
                });
                selectHandler();
              } else {
                Message.error({
                  content: res.message,
                  duration: 2000
                });
              }
            });
          },
        });
      } else {
        Message.info("请选择需要审核的数据");
      }
    };
    const exportHandler = () => {
      if (auditState.value === 0) {
        emitter.emit('exportsTestUnApprovedRows');
      } else {
        emitter.emit('exportsTestApprovedRows');
      }
    };
    const formRef = ref<FormInstance>();
    const saveHandler = () => {
      formRef.value?.validate().then(async (err) => {
        if (!err) {
          if (!pageData.billDate) {
            Message.info("请选择开单时间");
            return;
          }
          createTableData.dataForm.forEach(v => {
            v.billDate = pageData.billDate;
          });
          if (!createTableData.id) {
            await verfiyShrinkRegApi.addVerfiyShrinkReg([...createTableData.dataForm]).then((res: any) => {
              if (res.code === 200) {
                formRef.value?.resetFields();
                Message.success({
                  content: "新增成功",
                  duration: 5000,
                });
                pageData.showAdd = false;
                selectHandler();
              } else {
                Message.error({
                  content: res.message,
                  duration: 5000,
                });
              }
            });
          } else {
            await verfiyShrinkRegApi.editVerfiyShrinkReg([...createTableData.dataForm]).then((res: any) => {
              if (res.code === 200) {
                formRef.value?.resetFields();
                Message.success({
                  content: "编辑成功",
                  duration: 5000,
                });
                pageData.showAdd = false;
                selectHandler();
              } else {
                Message.error({
                  content: res.message,
                  duration: 5000,
                });
              }
            });
          }
        }
      });
    };
    const dyBoufeiHandler = () => {

    };
    const changHandler = (data: any) => {
      auditState.value = data;
      if (data === 0) {
        emitter.emit('shinkageTestUnApproved');
      } else {
        emitter.emit('shinkageTestApproved');
      }
    };

    const pageData = reactive<{
      showAdd: boolean;
      sideTitle: string;
      pageLoading: boolean;
      dropValList: any[];
      circulDropList: any[];
      circulatCard: any;
      billDate: string;
    }>({
      showAdd: false,
      sideTitle: "新增缩水测试原始资料登记",
      pageLoading: false,
      dropValList: [],
      circulDropList: [],
      circulatCard: '',
      billDate: "",
    });
    const scrollbar = ref(true);
    const {selectedRowKeys} = useRowSelection();
    const table = useTable();
    const rowKey = useRowKey("id");
    const tableColumns = [
      {
        title: "流转卡号",
        key: "circulatCard",
        dataIndex: "circulatCard",
        slotName: "circulatCard",
        width: 260,
      },
      {
        title: "客户",
        key: "customName",
        dataIndex: "customName",
        slotName: "customName",
        width: 260,
      },
      {
        title: "布号",
        key: "clothCode",
        dataIndex: "clothCode",
        slotName: "clothCode",
        width: 260,
      },
      {
        title: "品名",
        key: "brandName",
        dataIndex: "brandName",
        slotName: "brandName",
        width: 260,
      },
      {
        title: "颜色深浅",
        key: "colorDepth",
        dataIndex: "colorDepth",
        slotName: "colorDepth",
        width: 260,
      },
      {
        title: "色号",
        key: "colorCode",
        dataIndex: "colorCode",
        slotName: "colorCode",
        width: 260,
      },
      {
        title: "色称",
        key: "colorName",
        dataIndex: "colorName",
        slotName: "colorName",
        width: 260,
      },
      {
        title: "合约号",
        key: "contractNo",
        dataIndex: "contractNo",
        slotName: "contractNo",
        width: 260,
      },
      {
        title: "客户订单号",
        key: "customOrderNo",
        dataIndex: "customOrderNo",
        slotName: "customOrderNo",
        width: 260,
      },
      {
        title: "坯布批号",
        key: "greyBatch",
        dataIndex: "greyBatch",
        slotName: "greyBatch",
        width: 260,
      },
      {
        title: "坯布名称",
        key: "greyName",
        dataIndex: "greyName",
        slotName: "greyName",
        width: 260,
      },
      {
        title: "匹数",
        key: "pieceNum",
        dataIndex: "pieceNum",
        slotName: "pieceNum",
        width: 260,
      },
      {
        title: "设备编号",
        key: "deviceCode",
        dataIndex: "deviceCode",
        slotName: "deviceCode",
        width: 260,
      },
      {
        title: "定型机台",
        key: "shapMachine",
        dataIndex: "shapMachine",
        slotName: "shapMachine",
        width: 260,
      },
      {
        title: "预缩",
        key: "preshrunk",
        dataIndex: "preshrunk",
        slotName: "preshrunk",
        width: 260,
      },
      {
        title: "重量",
        key: "weight",
        dataIndex: "weight",
        slotName: "weight",
        width: 260,
      },
      {
        title: "胚洗前",
        width: 260,
        key: "embWashBefore",
        children: [
          {
            title: "克重",
            dataIndex: "firstGreyWashWeight",
            slotName: "firstGreyWashWeight",
            width: 260,
          },
          {
            title: "门幅",
            dataIndex: "firstGreyWashWidth",
            slotName: "firstGreyWashWidth",
            width: 260,
          },
        ]
      },
      {
        title: "胚洗后",
        width: 260,
        key: "embWashAfter",
        children: [
          {
            title: "克重",
            dataIndex: "afterGreyWashWeight",
            slotName: "afterGreyWashWeight",
            width: 260,
          },
          {
            title: "门幅",
            dataIndex: "afterGreyWashWidth",
            slotName: "afterGreyWashWidth",
            width: 260,
          },
        ]
      },
      {
        title: "定前",
        key: "finalizeBefore",
        width: 260,
        children: [
          {
            title: "克重",
            dataIndex: "firstSetWeight",
            slotName: "firstSetWeight",
            width: 260,
          },
          {
            title: "门幅",
            dataIndex: "firstSetWidth",
            slotName: "firstSetWidth",
            width: 260,
          },
        ]
      },
      {
        title: "还原",
        key: "reduction",
        width: 260,
        children: [
          {
            title: "克重",
            dataIndex: "reductionWeight",
            slotName: "reductionWeight",
            width: 260,
          },
          {
            title: "门幅",
            dataIndex: "reductionWidth",
            slotName: "reductionWidth",
            width: 260,
          },
        ]
      },
      {
        title: "定后",
        key: "finalizeAfter",
        dataIndex: "finalizeAfter",
        width: 260,
        children: [
          {
            title: "克重",
            dataIndex: "afterSetWeight",
            slotName: "afterSetWeight",
            width: 260,
          },
          {
            title: "门幅",
            dataIndex: "afterSetWidth",
            slotName: "afterSetWidth",
            width: 260,
          },
        ]
      },
      {
        title: "水洗尺寸变化率类型",
        key: "washSizeChangeRateType",
        dataIndex: "washSizeChangeRateType",
        slotName: "washSizeChangeRateType",
        width: 260,
      },
      {
        title: "洗前横向(%)",
        key: "washHorizontalBefore",
        width: 260,
        children: [
          {
            title: "1",
            dataIndex: "firstWashTransverse1",
            slotName: "firstWashTransverse1",
            width: 260,
          },
          {
            title: "2",
            dataIndex: "firstWashTransverse2",
            slotName: "firstWashTransverse2",
            width: 260,
          },
          {
            title: "3",
            dataIndex: "firstWashTransverse3",
            slotName: "firstWashTransverse3",
            width: 260,
          },
          {
            title: "平均值",
            dataIndex: "firstWashTransverseAvg",
            slotName: "firstWashTransverseAvg",
            width: 260,
          },
        ]
      },
      {
        title: "洗前直向(%)",
        key: "washStraightBefore",
        width: 260,
        children: [
          {
            title: "1",
            dataIndex: "firstWashStraight1",
            slotName: "firstWashStraight1",
            width: 260,
          },
          {
            title: "2",
            dataIndex: "firstWashStraight2",
            slotName: "firstWashStraight2",
            width: 260,
          },
          {
            title: "3",
            dataIndex: "firstWashStraight3",
            slotName: "firstWashStraight3",
            width: 260,
          },
          {
            title: "平均值",
            dataIndex: "firstWashStraightAvg",
            slotName: "firstWashStraightAvg",
            width: 260,
          },
        ]
      },
      {
        title: "洗后横向(%)",
        key: "washHorizontalAfter",
        width: 260,
        children: [
          {
            title: "1",
            dataIndex: "afterWashTransverse1",
            slotName: "afterWashTransverse1",
            width: 260,
          },
          {
            title: "2",
            dataIndex: "afterWashTransverse2",
            slotName: "afterWashTransverse2",
            width: 260,
          },
          {
            title: "3",
            dataIndex: "afterWashTransverse3",
            slotName: "afterWashTransverse3",
            width: 260,
          },
          {
            title: "平均值",
            dataIndex: "afterWashTransverseAvg",
            slotName: "afterWashTransverseAvg",
            width: 260,
          },
        ]
      },
      {
        title: "洗后直向%",
        key: "washStraightAfter",
        width: 260,
        children: [
          {
            title: "1",
            dataIndex: "afterWashStraight1",
            slotName: "afterWashStraight1",
            width: 260,
          },
          {
            title: "2",
            dataIndex: "afterWashStraight2",
            slotName: "afterWashStraight2",
            width: 260,
          },
          {
            title: "3",
            dataIndex: "afterWashStraight3",
            slotName: "afterWashStraight3",
            width: 260,
          },
          {
            title: "平均值",
            dataIndex: "afterWashStraightAvg",
            slotName: "afterWashStraightAvg",
            width: 260,
          },
        ]
      },
      {
        title: "缩水率(挂干)",
        key: "shrinkageHangdry",
        width: 260,
        children: [
          {
            title: "横向(%)",
            dataIndex: "shrinkageHangDryTransverse",
            slotName: "shrinkageHangDryTransverse",
            width: 260,
          },
          {
            title: "直向(%)",
            dataIndex: "shrinkageHangDryStraight",
            slotName: "shrinkageHangDryStraight",
            width: 260,
          },
        ]
      },
      {
        title: "缩水率(抛干)",
        key: "shrinkageHangdry",
        width: 260,
        children: [
          {
            title: "横向(%)",
            dataIndex: "shrinkageThrowDryTransverse",
            slotName: "shrinkageThrowDryTransverse",
            width: 260,
          },
          {
            title: "直向(%)",
            dataIndex: "shrinkageThrowDryStraight",
            slotName: "shrinkageThrowDryStraight",
            width: 260,
          },
        ]
      },
      {
        title: "缩水率(平干)",
        key: "shrinkageFlatdry",
        width: 260,
        children: [
          {
            title: "横向(%)",
            dataIndex: "shrinkageFlatDryTransverse",
            slotName: "shrinkageFlatDryTransverse",
            width: 260,
          },
          {
            title: "直向(%)",
            dataIndex: "shrinkageFlatDryStraight",
            slotName: "shrinkageFlatDryStraight",
            width: 260,
          },
        ]
      },
      {
        title: "扭度(挂干)%",
        key: "torsionHangDry",
        dataIndex: "torsionHangDry",
        slotName: "torsionHangDry",
        width: 260,
      },
      {
        title: "扭度(抛干)%",
        key: "torsionThrowDry",
        dataIndex: "torsionThrowDry",
        slotName: "torsionThrowDry",
        width: 260,
      },

      {
        title: "扭度(平干)%",
        key: "torsionFlatDry",
        dataIndex: "torsionFlatDry",
        slotName: "torsionFlatDry",
        width: 260,
      },
      {
        title: "洗后克重(挂干)%",
        key: "washWeightHangDry",
        dataIndex: "washWeightHangDry",
        slotName: "washWeightHangDry",
        width: 260,
      },
      {
        title: "洗后克重(抛干)%",
        key: "washWeightThrowDry",
        dataIndex: "washWeightThrowDry",
        slotName: "washWeightThrowDry",
        width: 260,
      },
      {
        title: "洗后克重(平干)%",
        key: "washWeightFlatDry",
        dataIndex: "washWeightFlatDry",
        slotName: "washWeightFlatDry",
        width: 260,
      },
      {
        title: "要求门幅",
        key: "requireWidth",
        dataIndex: "requireWidth",
        slotName: "requireWidth",
        width: 260,
      },
      {
        title: "有效门幅",
        key: "validWidth",
        dataIndex: "validWidth",
        slotName: "validWidth",
        width: 260,
      },
      {
        title: "要求克重",
        key: "requireWeight",
        dataIndex: "requireWeight",
        slotName: "requireWeight",
        width: 260,
      },
      {
        title: "实测克重",
        key: "measuredWeight",
        dataIndex: "measuredWeight",
        slotName: "measuredWeight",
        width: 260,
      },
      {
        title: "顶破强力",
        key: "burstStrength",
        dataIndex: "burstStrength",
        slotName: "burstStrength",
        width: 260,
      },
      {
        title: "胀破强力",
        key: "dilapidationStrength",
        dataIndex: "dilapidationStrength",
        slotName: "dilapidationStrength",
        width: 260,
      },
      {
        title: "耐日晒色牢度",
        key: "SunColorFastness",
        dataIndex: "SunColorFastness",
        slotName: "SunColorFastness",
        width: 260,
      },
      {
        title: "耐酚黄色牢度",
        key: "phenolYellowColorFastness",
        dataIndex: "phenolYellowColorFastness",
        slotName: "phenolYellowColorFastness",
        width: 260,
      },
      {
        title: "PH值",
        key: "phValue",
        dataIndex: "phValue",
        slotName: "phValue",
        width: 260,
      },
      {
        title: "甲醛",
        key: "formaldehyde",
        dataIndex: "formaldehyde",
        slotName: "formaldehyde",
        width: 260,
      },
      {
        title: "纬斜",
        key: "latitudinalObliquity",
        dataIndex: "latitudinalObliquity",
        slotName: "latitudinalObliquity",
        width: 260,
      },
      {
        title: "耐光、汗复合色牢度",
        key: "colourAndLightPerspiration",
        width: 260,
        children: [
          {
            title: "酸",
            dataIndex: "lightSweatColorFastnessSour",
            slotName: "lightSweatColorFastnessSour",
            width: 260,
          },
          {
            title: "碱",
            dataIndex: "lightSweatColorFastnessAlkali",
            slotName: "lightSweatColorFastnessAlkali",
            width: 260,
          },
        ]
      },
      {
        title: "泡水",
        key: "soakWater",
        dataIndex: "soakWater",
        slotName: "soakWater",
        width: 260,
      },
      {
        title: "纵密(CPI)",
        key: "verticalDensityCPI",
        dataIndex: "verticalDensityCPI",
        slotName: "verticalDensityCPI",
        width: 260,
      },
      {
        title: "横密(WPI)",
        key: "transverseDensityCPI",
        dataIndex: "transverseDensityCPI",
        slotName: "transverseDensityCPI",
        width: 260,
      },
      {
        title: "耐摩擦色牢度",
        key: "rubbingColourFastness",
        width: 260,
        children: [
          {
            title: "干",
            dataIndex: "frictionColorFastnessDry",
            slotName: "frictionColorFastnessDry",
            width: 260,
          },
          {
            title: "湿(浅色)",
            dataIndex: "frictionColorFastnessWetTint",
            slotName: "frictionColorFastnessWetTint",
            width: 260,
          },
          {
            title: "湿(深色)",
            dataIndex: "frictionColorFastnessWetDark",
            slotName: "frictionColorFastnessWetDark",
            width: 260,
          },
        ]
      },
      {
        title: "耐皂洗色牢度",
        key: "soapWashColorFastness",
        dataIndex: "soapWashColorFastness",
        slotName: "soapWashColorFastness",
        width: 260,
      },
      {
        title: "耐汗渍色牢度",
        key: "perspirationColourFastness",
        width: 260,
        children: [
          {
            title: "酸",
            dataIndex: "stainColorFastnessSour",
            slotName: "stainColorFastnessSour",
            width: 260,
          },
          {
            title: "碱",
            dataIndex: "stainColorFastnessAlkali",
            slotName: "stainColorFastnessAlkali",
            width: 260,
          },
        ]
      },
      {
        title: "耐水色牢度",
        key: "waterColorFastness",
        dataIndex: "waterColorFastness",
        slotName: "waterColorFastness",
        width: 260,
      },
      {
        title: "扛起球",
        key: "resistPill",
        dataIndex: "resistPill",
        slotName: "resistPill",
        width: 260,
      },
      {
        title: "耐唾液色牢度",
        key: "salivaColorFastness",
        dataIndex: "salivaColorFastness",
        slotName: "salivaColorFastness",
        width: 260,
      },
      {
        title: "备注",
        key: "remark",
        dataIndex: "remark",
        slotName: "remark",
        width: 260,
      },
      {
        title: "用量",
        key: "consumption",
        dataIndex: "consumption",
        slotName: "consumption",
        width: 260,
      },
      {
        title: "测试标准",
        key: "verifyStandard",
        dataIndex: "verifyStandard",
        slotName: "verifyStandard",
        width: 260,
      },
    ];
    const createTableColumns = useTableColumn([...tableColumns]);
    const dataFormItem = {
      billDate: "",
      circulatCard: "",
      customName: "",
      clothCode: "",
      brandName: "",
      colorDepth: "",
      colorCode: "",
      colorName: "",
      contractNo: "",
      customOrderNo: "",
      greyBatch: "",
      greyName: "",
      pieceNum: "",
      deviceCode: "",
      shapMachine: "",
      preshrunk: "",
      weight: 0,
      firstGreyWashWeight: 0,
      firstGreyWashWidth: "",
      afterGreyWashWeight: 0,
      afterGreyWashWidth: "",
      firstSetWeight: 0,
      firstSetWidth: "",
      reductionWeight: 0,
      reductionWidth: "",
      afterSetWeight: 0,
      afterSetWidth: "",
      washSizeChangeRateType: 0,
      firstWashTransverse1: 0,
      firstWashTransverse2: 0,
      firstWashTransverse3: 0,
      firstWashTransverseAvg: 0,
      firstWashStraight1: 0,
      firstWashStraight2: 0,
      firstWashStraight3: 0,
      firstWashStraightAvg: 0,
      afterWashTransverse1: 0,
      afterWashTransverse2: 0,
      afterWashTransverse3: 0,
      afterWashTransverseAvg: 0,
      afterWashStraight1: 0,
      afterWashStraight2: 0,
      afterWashStraight3: 0,
      afterWashStraightAvg: 0,
      shrinkageHangDryTransverse: 0,
      shrinkageHangDryStraight: 0,
      shrinkageFlatDryTransverse: 0,
      shrinkageFlatDryStraight: 0,
      shrinkageThrowDryTransverse: 0,
      shrinkageThrowDryStraight: 0,
      torsionHangDry: 0,
      torsionThrowDry: 0,
      torsionFlatDry: 0,
      washWeightHangDry: 0,
      washWeightThrowDry: 0,
      washWeightFlatDry: 0,
      requireWidth: "",
      validWidth: "",
      requireWeight: 0,
      measuredWeight: 0,
      burstStrength: 0,
      dilapidationStrength: 0,
      SunColorFastness: 0,
      phenolYellowColorFastness: 0,
      phValue: 0,
      formaldehyde: 0,
      latitudinalObliquity: 0,
      lightSweatColorFastnessSour: 0,
      lightSweatColorFastnessAlkali: 0,
      soakWater: 0,
      verticalDensityCPI: 0,
      transverseDensityCPI: 0,
      frictionColorFastnessDry: 0,
      frictionColorFastnessWetTint: 0,
      frictionColorFastnessWetDark: 0,
      soapWashColorFastness: 0,
      stainColorFastnessSour: 0,
      stainColorFastnessAlkali: 0,
      waterColorFastness: 0,
      resistPill: 0,
      salivaColorFastness: 0,
      remark: "",
      consumption: 0,
      verifyStandard: ""
    };
    const createTableData = reactive<{
      id: any;
      dataForm: shinkageTestForm[];
    }>({
      id: null,
      dataForm: [{...dataFormItem}]
    });


    return {
      addHandler,
      selectHandler,
      exportHandler,
      auditHandler,
      searchData,
      scrollbar,
      // pagination,
      selectedRowKeys,
      table,
      rowKey,
      pageData,
      saveHandler,
      dyBoufeiHandler,
      createTableColumns,
      createTableData,
      seatchHandler,
      selecChange,
      changHandler,
      selectChange,
      options,
      loading,
      formRef,
      changHeadShow,
      headerShow,
      changAuids,
      auditState
    };
  },
  components: {PageTabelLayout}
}
</script>


<style scoped>
.main-container {
  height: 100%;
}


.bacClass {
  width: 270px;
  background: #fff;
  border: 1px solid #c9cdd3;
}

.cInput {
  background: #fff;
  border: 1px solid #c9cdd3;
}

:deep(.arco-picker input) {
  padding-left: 0 !important;
}

:deep(.arco-picker) {
  padding-left: 0 !important;
}

:deep(.arco-picker-separator) {
  padding: 0 !important;
}
</style>